<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 
     canvas三要素
     id:唯一标识
     width:画布内容宽度的像素大小
     height:画布内容高度的像素大小
   -->
    <canvas id="canvas1" width="800" height="600">
      这里的内容画布是不显示的
    </canvas>
  </body>
  <script>
    //1.找到画布对象和视频对象
    var canvas1 = document.querySelector("#canvas1");
    //2.找到上下文对象(画笔对象)这边是2d引擎的
    var ctx = canvas1.getContext("2d");
    //3.绘制视频
    var interId;
    var img = new Image();
    img.src =
      "https://img1.baidu.com/it/u=2201501474,2671231298&fm=26&fmt=auto";
    img.onload = function () {
      ctx.drawImage(img, 50, 50, 200, 200);
    };
  </script>
</html>
